﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using MVVMFramework.View;

namespace SvnMonitor
{
    /// <summary>
    /// Interaction logic for NotificationView.xaml
    /// </summary>
    partial class NotificationView : WindowBase
    {
        private readonly NotificationVM vm;

        public NotificationView(NotificationVM vm)
            : base(vm)
        {
            this.vm = vm;

            InitializeComponent();
        }

        private void updateToLatestVersionHyperlink_OnRequestNavigate(object sender, RequestNavigateEventArgs e)
        {
            try
            {
                vm.UpdateToLatestVersion();

                Close();
            }
            catch (Exception ex)
            {
                Logger.Instance.Error("An error has occurred updating to latest version", ex);
                ViewManager.ShowException("An error has occurred updating to latest version", ex);
            }
        }

        private void window_OnMouseDown(object sender, MouseButtonEventArgs e)
        {
            Close();
        }
    }
}
